package com.erp.servlet;

import com.erp.bean.Entrepot;
import com.erp.service.EntrepotService;
import com.erp.service.impl.EntrepotServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lyb
 * 实现仓库修改控制器
 */
@WebServlet("/updateee.action")
public class UpdateEntrepoteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //接收仓库信息
        String id=req.getParameter("entid");
        int entid=Integer.valueOf(id);
        String name=req.getParameter("deptname");
        String lo=req.getParameter("loc");
        //创建仓库业务逻辑对象
        EntrepotService entrepotService=new EntrepotServiceImpl();
        Entrepot entrepot=entrepotService.findByentid(entid);
        entrepot.setEntname(name);
        entrepot.setLoc(lo);
        entrepotService.update(entrepot);
        //重定向到仓库列表控制器
        resp.sendRedirect("entrepotlist.action");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
